Skip to content

fourteen-testing-api - During model transform preserve the argument p…#115

Closed
jbryson3 wants to merge 2 commits intoember-codemods:masterfrom
jbryson3:feature/model-arguments-to-createRecord
Closed

fourteen-testing-api - During model transform preserve the argument p…#115
jbryson3 wants to merge 2 commits intoember-codemods:masterfrom
jbryson3:feature/model-arguments-to-createRecord

Conversation

@jbryson3
Copy link
Copy Markdown
Contributor

@jbryson3 jbryson3 commented Feb 4, 2020

…assed to this.subject

During my conversion to 0.14 testing api, I found that all the arguments I was passing to this.subject() in my model tests were getting blown away.

//input
let model = this.subject({key: 'value'})
//output
let model = this.owner.lookup(%model%).createRecord();

This PR will preserve the argument passed to this.subject and additionally wrap it in a run loop to avoid the "You have turned on testing mode, which disabled the run-loop's autorun." error during testing.

//input
let model = this.subject({key: 'value'})
//output
let model = Ember.run(
  () => this.owner.lookup(%model%).createRecord({key: 'value'})
);

@Turbo87
Copy link
Copy Markdown
Collaborator

Turbo87 commented Feb 5, 2020

hmm, I think with more recent versions of Ember the runloop wrapping should not be necessary anymore. maybe we should make that optional?

@jbryson3
Copy link
Copy Markdown
Contributor Author

jbryson3 commented Feb 5, 2020

Oh that's great news (about the run-loop). I'm upgrading our testing framework from ember-cli-mocha to ember-mocha and including the changes in the 0.14 testing api's. The ember app is currently sitting at 2.13, so I'm glad to hear that once I upgrade, the run-loop isn't going to be necessary.

I will look into how to pass optionality to the transform. Thanks!

@jbryson3
Copy link
Copy Markdown
Contributor Author

jbryson3 commented Feb 14, 2020

I'm going to split this PR into 2

  1. Preserving the arguments passed to this.subject() - During model transform preserve the argument passed to this.subject #116
  2. Wrapping with run loop for older versions of ember - Add option to wrap model.createRecord in runloop #117

This is to isolate the argument passing, from the more opinionated and specific changes for wrapping with a run loop.

@jbryson3 jbryson3 closed this Feb 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants